<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'authUser.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="../css/counter.css">
		<link rel="stylesheet" type="text/css" href="../css/css.css">
		<script src="<%=basePath%>/javascript/jquery.js"></script>
		<script src="<%=basePath%>/javascript/listtolist.js"></script>
		<script type="text/javascript"> 
 		$(document).ready(function() { 
 		 $("#selectAll").click(function(){$(":checkbox").attr("checked","true");});
 		 
         $("#cancleSelectAll").click(function(){$(":checkbox").removeAttr("checked");});
         
      		 $(":checkbox").each(function(){
       				$(this).click(function(){
          				 checkNode(this);
       				 });
       			});    
		}); 
      function checkNode(self)
      {
      var parent_id=$(self).attr("parentId");
      var self_id=$(self).attr("id");
      
        //如果本身节点有父节点的话，就需要判断父节点是否选中
       if(parent_id!='0'){ 
           var parentNode=$(":checkbox[@id='"+parent_id+"']"); 
              //父类选中的话，如过自己选中的话，让所有子类选中,否则全部不选中
           if(parentNode.attr("checked")==true){    
                $(":checkbox[@parentId='"+self_id+"']").each(function(){            
                    if($(self).attr("checked")==true){    
                       $(this).attr("checked","checked");
                    }else{
                       $(this).removeAttr("checked");    
                    }
                });
           }else{
                //如果父类没有选中的话，则本身和子类都不能选中
                $(self).removeAttr("checked");
                $(":checkbox[@parentId='"+self_id+"']").each(function(){    
                       $(this).removeAttr("checked");    
                });
            }
       }else{
            //如果该节点没有父节点，就只需根据本身的选中与否来选中子节点
           $(":checkbox[@parentId='"+self_id+"']").each(function(){
                if($(self).attr("checked")==true){
                   $(this).attr("checked","checked");
                }else{
                    $(this).removeAttr("checked");        
                }
           });       
       }
      
      
      }       
</script>

	</head>

	<body>
		<center>
			<form action="admin/authRole.action" method="post">
				<table width="100%" cellpadding="0" cellspacing="0"
					bgcolor="#ffffff">
					<tr>
						<td>

							<TABLE height="80%" cellSpacing=1 cellPadding=2 width="100%"
								bgColor=#ffffff border=0>
								<TBODY>
									<TR class=bg height=23>
										<td width="4%" background="../images/manage/title_bg.jpg"
											class="font_12_B_w">
											<IMG src="<%=basePath%>/images/manage/arron1.gif">
											快速授权

										</TD>
									</TR>
								</TBODY>
							</TABLE>
							<input type="hidden" name="roleId" />
							<TABLE height="100%" cellSpacing=1 cellPadding=2 width="100%"
								bgColor=#ffffff border=0>
								<tr>
									<td bgcolor="#EAEEEE">
										模块列表
										<input type="button" id="selectAll" value="选择所有">
										<input type="button" id="cancleSelectAll" value="取消选择所有">
									</td>
								</tr>
								${moduleString}
							</TABLE>

							<table width="100%" border="0" cellpadding="0" cellspacing="0"
								bgcolor="#EAEEEE">
								<tr>
									<td>
										<CENTER>
											<input type="submit" id="tj" value="提交授权">

											&nbsp;&nbsp;
											<input type="button" onclick="window.close()" name="qx"
												value="关闭窗口">

										</CENTER>
									</td>
								</tr>
							</table>

						</td>
					</tr>
				</table>
			</form>
		</center>
	</body>
</html>
